import requests

def main(sql: str) -> dict:
    url = "http://host.docker.internal:5000/execute_sql"
    connection_info = {
        "host": "localhost",
        "user": "user",
        "password": "Password",
        "database": "mydb",
        "port": 3136
    }
    # 构造请求体
    payload = {
        "sql": sql,
        "connection_info": connection_info
    }

    headers = {
        "Content-Type": "application/json"
    }

    try:
        response = requests.post(url, json=payload, headers=headers)
        if response.status_code == 200:
            try:
                return {"result": str(response.json()["result"])}
            except Exception as e:
                return {"result": f"解析响应 JSON 失败：{str(e)}"}
        else:
            return {"result": f"请求失败，状态码：{response.status_code}"}
    except Exception as e:
        return {"result": str(e)}